package cn.smart.epic.config;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther Uncle_Z
 * @date 2017/9/6 20:42
 * @Email:2545375@qq.com
 * @Descrition
 * @since 1.0
 */
@Configuration
public class FastjsonConfig {

    @Bean
    public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        converter.setDateFormat("yyyy-MM-dd HH:mm:ss");
        converter.setFeatures(SerializerFeature.PrettyFormat,SerializerFeature.WriteMapNullValue);
        //ValueFilter valueFilter = (o1, o2, o3) -> {
        //    if (o3 == null) {
        //        o3 = "";
        //    }
        //    return o3;
        //};
        //converter.addSerializeFilter(valueFilter);
        return converter;
    }


}
